﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Collections.Generic;

namespace AIC_CD
{
    public class MyFromBase : System.Web.UI.Page
    {

        public string sID
        {
            get
            {
                if (null == ViewState["ID"])
                    return string.Empty;
                else
                    return (string)ViewState["ID"];
            }
            set { ViewState["ID"] = value; }
        }
        public List<SqlParameter> MyReportParams
        {
            get
            {
                if (Session["rptParams"] == null) return new List<SqlParameter>();
                return (List<SqlParameter>)Session["rptParams"];
            }
            set { Session["rptParams"] = value; }
        }
        public string MyTableName
        {
            get
            {
                if (Session["rptTableName"] == null) return "";
                return Session["rptTableName"].ToString();
            }
            set { Session["rptTableName"] = value; }
        }
        public string MyReportSQL
        {
            get
            {
                if (Session["rptSQL"] == null) return "";
                return Session["rptSQL"].ToString();
            }
            set { Session["rptSQL"] = value; }
        }
        /// <summary>
        /// chuỗi querry lấy bảng tham số
        /// </summary>
        public string MyReportSQLParam
        {
            get
            {
                if (Session["rptSQLParam"] == null) return "";
                return Session["rptSQLParam"].ToString();
            }
            set { Session["rptSQLParam"] = value; }
        }
        public string MyReportName
        {
            get
            {
                if (Session["rptName"] == null) return "";

                return Session["rptName"].ToString();
            }
            set { Session["rptName"] = value; }
        }
        public string sSort
        {
            get
            {
                if (null == ViewState["Sort"])
                    return null;
                else
                    return (string)ViewState["Sort"];
            }
            set { ViewState["Sort"] = value; }
        }

        /// <summary>
        /// Thủ tục gán các script cho gridview để di chuyển chuột đến dòng nào thì dòng đó sáng lên.
        /// Nếu click vào ô đầu tiên thì sẽ gửi sự kiện chọn dòng đó
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                e.Row.Style["cursor"] = "hand";
                e.Row.Attributes.Add("onmouseover", "this.originalcolor=this.style.backgroundColor; this.style.backgroundColor='#ebecec';");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalcolor;");
                //  e.Row.Cells[0].Attributes["OnClick"] = Page.ClientScript.GetPostBackEventReference(((System.Web.UI.Control)sender), "Select$" + e.Row.RowIndex);
            }
            
        }
    }
}
